# -*- coding: utf-8 -*-
#-----------------------------------------
# @Time       : 2020/2/11 17:11
# @Author     : dqz 
# @Email      : 1406990390@qq.com
# @File       : ding.py
# @Software   : PyCharm
#-----------------------------------------

import requests
from config.settings import CONNECT_TIMEOUT

class Ding:
    def __init__(self,token):
        self.url=f"https://oapi.dingtalk.com/robot/send?access_token={token}"
        self.headers={"content-Type":"application/json;charset=UTF-8"}

    def send_text(self,title,text):
        textMsg = {
            "msgtype": "text",
            "text": {"content": f"{title}:{text}"}
        }
        try:
            requests.post(self.url,json=textMsg,headers=self.headers,timeout=CONNECT_TIMEOUT)
        except Exception as e:
            pass
